# -*- coding: utf-8 -*-
"""
@Author: 王少杰
@Date: 2025/8/28
@Time: 12:25
@FileName: login_page.py
@描述:
"""
import time

from selenium.webdriver.common.by import By
from src.pages.base_page import BasePage


# 定义一个类，用来封装 登录页面元素的定位表达式以及元素对应的操作
# 而且该类还要继承BasePage类

class LoginPage(BasePage):
    # 用户名
    username_ele = (By.CLASS_NAME, 'el-input__inner')
    # 密码
    password_ele = (By.XPATH, '//*[@id="app"]/div[2]/div[2]/div[2]/div/input')
    # button
    button_ele = (By.CLASS_NAME, 'el-button')

    # 定义一个方法，用来登录系统
    def login(self, username, password):
        # 定位到用户名输入框并输入用户名
        self.find_ele_explicitly(self.username_ele).send_keys(username)
        # 定位到密码输入框并输入密码
        self.find_ele_explicitly(self.password_ele).send_keys(password)
        # 定位到登录按钮并点击他
        self.find_ele_explicitly(self.button_ele).click()
        time.sleep(10)

if __name__ == '__main__':
    from selenium import webdriver
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get('https://jxc.aesd.cn/login')
    LoginPage(driver).login('test','123456')